package com.pignest.framework.ajax;

import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteProperty;

@DataTransferObject
public class AjaxResult {

	public static final int RESULT_SUCCESS = 1;
	public static final int RESULT_FAIL = 2;
	public static final int RESULT_CONFIRM = 3;
	
	@RemoteProperty
	private int result;
	@RemoteProperty
	private String description;
//	@RemoteProperty
//	private AjaxObject result;
	
	public AjaxResult() {
	}
	
	public static AjaxResult fail(String desc) {
		AjaxResult r = new AjaxResult();
		r.setResult(RESULT_FAIL);
		r.setDescription(desc);
		return r;
	}
	public static AjaxResult success() {
		AjaxResult r = new AjaxResult();
		r.setResult(RESULT_SUCCESS);
		return r;
	}
	public static AjaxResult confirm(String desc) {
		AjaxResult r = new AjaxResult();
		r.setResult(RESULT_CONFIRM);
		r.setDescription(desc);
		return r;
	}
	
	public int getResult() {
		return result;
	}
	public void setResult(int state) {
		this.result = state;
	}
//	public AjaxObject getResult() {
//		return result;
//	}
//	public void setResult(AjaxObject result) {
//		this.result = result;
//	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
}
